Ext.define('PJ.view.codtrainingprogram.ConfirmationNumber', {
	extend: 'AM.default.DefaultWindowForm',
	alias: ['widget.confirmationNumber'],
	requires: ['AM.default.jsonp.DefaultSubmitJsonp',
	           'AM.default.DefaultDateField'],

	modal: true,// 开启不允许点击其他组件
	frame: true,
	notEdit: true,
	width: 350,
	height:105,
	layout: 'form',
	isSame: false,
	autoHeight: true,

	initComponent: function(){
    	var me = this;
    	var bt = '<span style="color:red;">*</span>';
    	me.items= [{
    		border: false,
    		xtype: "container",
    		width: 320,
    		layout: 'column',
    		items: [{
    			xtype: 'textfield',
    			readOnly:false,
    			fieldLabel: bt + '培训班编号',
    			labelAlign: 'right',
    			labelWidth: 80,
    			name: 'coursesNum',
    			value:me.classNum,
    			allowBlank: true,
    			columnWidth: 1,
    			regex: /^[0-9]{1,7}$/,
    			regexText: '培训班编号只能输入7位长度的数字！'
    		}]
    	}];
    	this.buttons = [{
            text: '确定',
            handler: function(button, event){
                var win = button.up('window');
                win.sub();
            }
        }, {
            text: '关闭',
            scope: this,
            handler: function(button, event){
                var win = button.up('window');
                win.close();
            }
        }];
		this.callParent(arguments);
	},
    sub:function(){
		var win = this;
		var form = win.down('form');
		var baseForm = form.getForm();
		if (!baseForm.isValid()) {
			return;
		}
		if(gj_onlineLearning_constant.loadType == "jsonp"){
			baseForm.doAction('submitJsonp',{
				submitEmptyText: false,//忽略emptyValue
				url: win.grid.store.postTrainingProgramUrl,
				params: {
					searchPlanIds: win.searchPlanIds
				},
				success: function(f, action){
					if (action.result.success) {
						Orchid.alert('消息', "发布成功!", function(){
							var gridPanel = win.grid;
							var store = gridPanel.getStore();
							store.reload();
							win.close();
						});
					}else{
						Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
				}
			});
		}else{
			form.submit({
				submitEmptyText: false,//忽略emptyValue
				url: win.grid.store.postTrainingProgramUrl,
				params: {
					searchPlanIds: win.searchPlanIds
				},
				success: function(f, action){
					if (action.result.success) {
						Orchid.alert('消息', "发布成功!", function(){
							var gridPanel = win.grid;
							var store = gridPanel.getStore();
							store.reload();
							win.close();
						});
					}else{
						Orchid.alert('消息', action.result.msg||"系统出错,请联系管理员!", function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					Orchid.alert('错误', action.result.msg||"系统出错,请联系管理员!");
				}
			});
		}
    }
});